package com.qunar.tech.team12.shell.io.impl;

import com.google.common.collect.Lists;
import com.qunar.tech.team12.shell.io.Input;
import com.qunar.tech.team12.shell.io.Output;

import java.util.List;
import java.util.Queue;

/**
 * Created by mzy on 14-7-23.
 */
public class Pipeline implements Input, Output {

    private static final Queue<String> queue = Lists.newLinkedList();

    @Override
    public List<String> read() {
        List<String> result = Lists.newArrayList(queue);
        queue.clear();
        return result;
    }

    @Override
    public void write(String out) {
        queue.add(out);
    }

    public void writeAll(List<String> outs) {
        queue.addAll(outs);
    }
}
